// pages/index/component/travleRow/travleRow.js
const app=getApp()
import { list, getArea } from '../../../../api/scenicSpot'
const util = require('../../../../utils/util')
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    info:{
      type:Object
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
      travlelist:[]
  },
  
  lifetimes:{
    attached(){
      this.loadlist()
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    toDetail(data){
      
      wx.navigateTo({
        url: `/pages/travel/travel/index?scenicSpotId=${data.currentTarget.dataset.id}`,
      })
    },
    loadlist(){
      list().then(res=>{
        res.data.data.forEach(item=>{
          item.thumbnail=util.thumbnail(item.thumbnail, 253, 232)
          if(util.isNull(item.score)){
            item.score=0
          }else{
            item.score=Number(item.score).toFixed(0)
          }
          item.score = 5 // TODO 默认五星
          item.number=[]
          for(var i=0;i<5;i++){
            if(i<item.score){
              item.number.push('https://rzico.oss-cn-shenzhen.aliyuncs.com/dinnerBar/ic_list_star_red%402x.png')
            }else{
              item.number.push('http://rzico.oss-cn-shenzhen.aliyuncs.com/dinnerBar/dingdan/bddd9200c54aea2f8e84ca2b75a0ee8.png')
            }
           
          }

          
          this.data.travlelist.push(item)
        })
        this.setData({
          travlelist:this.data.travlelist
        })
      })
    }
  }
})
